<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="s_tech_process" :rules="rules" label-width="100px" id="mvcfm">
          <div class="form-unit">
            <span class="mvc-title-left"> 设定工位 </span>
          </div>
          <el-table :data="s_tech_process">
            <el-table-column label="工序" prop="plan_processid">
            </el-table-column>
            <el-table-column label="工位" prop="plan_positionid">
              <template slot-scope="scope"> process_id={{emt.map['process_id']}}
                <el-button @click="popSetStationChoice('plan_positionid','plan_positionid')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
              </template>
            </el-table-column>
          </el-table>
          <el-button @click="productTechSetStationSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/mes/product/TechProcedure?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'适用产品'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="SetStationChoiceVisible" append-to-body>
      <SetStationChoice v-if="SetStationChoiceVisible" ref="SetStationChoice" :popparams="popparams"> </SetStationChoice>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SetStationChoice from "@/views/mes/product/SetStationChoice";
  export default {
    name: 'ProductTechSetStation',
    components: {
      SetStationChoice,
    },
    props: ['popparams'],
    data() {
      return {
        SetStationChoiceVisible: false,
        SetStationChoiceValue: null,
        SetStationChoiceDesc: null,
        vueparams: this.getVUEParams(""),
        s_tech_process: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "28847805EE1D403DBCD43478FD18BD08",
        name: "工艺右菜单",
        selected: "适用产品"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/productTechSetStation?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      productTechSetStationSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/product/TechnologyAction/productTechSetStationSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/product/SetStationDet/setStationDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popSetStationChoice(desc, value) {
        this.SetStationChoiceVisible = true;
        this.SetStationChoiceDesc = desc;
        this.SetStationChoiceValue = value;
      },
      closeSetStationChoice(value, desc) {
        this.SetStationChoiceVisible = false;
        this.$set(this.s_tech_process, this.SetStationChoiceDesc, desc);
        this.$set(this.s_tech_process, this.SetStationChoiceValue, value);
      },
    },
  }
</script>
